package com.ruoyi.jcsj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jcsj.domain.TIpassSchool;
import com.ruoyi.jcsj.service.ITIpassSchoolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 一卡通校园配置Controller
 *
 * @author ruoyi
 * @date 2023-04-10
 */
@RestController
@RequestMapping("/jcsj/school")
public class TIpassSchoolController extends BaseController
{
    @Autowired
    private ITIpassSchoolService tIpassSchoolService;

    /**
     * 查询一卡通校园配置列表
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIpassSchool tIpassSchool)
    {
        startPage();
        List<TIpassSchool> list = tIpassSchoolService.selectTIpassSchoolList(tIpassSchool);
        return getDataTable(list);
    }

    /**
     * 导出一卡通校园配置列表
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:export')")
    @Log(title = "一卡通校园配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TIpassSchool tIpassSchool)
    {
        List<TIpassSchool> list = tIpassSchoolService.selectTIpassSchoolList(tIpassSchool);
        ExcelUtil<TIpassSchool> util = new ExcelUtil<TIpassSchool>(TIpassSchool.class);
        util.exportExcel(response, list, "一卡通校园配置数据");
    }

    /**
     * 获取一卡通校园配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tIpassSchoolService.selectTIpassSchoolById(id));
    }

    /**
     * 新增一卡通校园配置
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:add')")
    @Log(title = "一卡通校园配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIpassSchool tIpassSchool)
    {
        return toAjax(tIpassSchoolService.insertTIpassSchool(tIpassSchool));
    }

    /**
     * 修改一卡通校园配置
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:edit')")
    @Log(title = "一卡通校园配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIpassSchool tIpassSchool)
    {
        return toAjax(tIpassSchoolService.updateTIpassSchool(tIpassSchool));
    }

    /**
     * 删除一卡通校园配置
     */
    @PreAuthorize("@ss.hasPermi('jcsj:school:remove')")
    @Log(title = "一卡通校园配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tIpassSchoolService.deleteTIpassSchoolByIds(ids));
    }
}
